package org.test.jiazi_1.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.test.jiazi_1.config.Constant;
import org.test.jiazi_1.mapper.CourseMapper;
import org.test.jiazi_1.mapper.StudentMapper;
import org.test.jiazi_1.pojo.entity.Course;
import org.test.jiazi_1.pojo.entity.Fitness;
import org.test.jiazi_1.mapper.FitnessMapper;
import org.test.jiazi_1.pojo.entity.Student;
import org.test.jiazi_1.service.CourseService;
import org.test.jiazi_1.service.FitnessService;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Collection;
import java.util.List;

/**
 * 体测项目成绩表(Fitness)表服务实现类
 *
 * @author 2251300222 唐文涛
 * @since 2025-10-24 13:28:07
 */
@Slf4j
@Service("fitnessService")
public class FitnessServiceImpl extends ServiceImpl<FitnessMapper, Fitness> implements FitnessService {

    @Resource
    private StudentMapper studentMapper;
    @Resource
    private CourseMapper courseMapper;
    @Override
    public boolean getGrade(Fitness fitness) {
        //根据studentId查询学生信息
        Course course = courseMapper.selectById(fitness.getCourseId());
        Integer grade = course.getGradeId();
        //41,42 true 43,44 false
        return grade.equals(41) || grade.equals(42);
    }

    @Override
    public boolean getMale(Fitness fitness) {
        //根据studentId查询学生信息
        Student student = studentMapper.selectById(fitness.getStudentId());
        return student.getGender().equals(Constant.GENDER_MALE);
    }

    @Override
    public Collection<Fitness> getListByCourseId(Integer courseId) {
        return baseMapper.selectList(new LambdaQueryWrapper<Fitness>().eq(Fitness::getCourseId, courseId));
    }
}
